package com.heaven.core.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.*;

@Data
@Document("user")
@NoArgsConstructor
public class UserEntity implements Serializable {

    @Id
    private String userId;

    /** 邮箱(可用于登录) **/
    @Indexed(unique = true, background = true)
    private String email;

    /** 手机号(可用于登录) **/
    private String phone;

    /** 登录密码 **/
    private String password;

    /** 昵称 **/
    @Indexed(unique = true, background = true)
    private String nickname;

    /** 头像(存储在minio中)- {bucketName}:{objectName} **/
    private String header;

    /** 性别: 0-女，1-男 */
    private Integer gender;

    /** 启用状态：0-禁用，1-启用 */
    private Integer status;

    /** 注册时间 , mongodb存储的时间会比实际的早8H，但进过服务转化会自动添加8H */
    //@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 个人简介*/
    private String introduce;

    /** 关注用户ID列表 */
    private Set<String> subscribeUsers;

    /** 关注视频ID列表 */
    private Set<String> subscribeVideos;

    /** 关注文贴ID列表 */
    private Set<String> subscribeArticles;

    /** 聊天对象ID列表 */
    private Set<String> chatTargetIds;

    public UserEntity(String email, String password, String nickname, String header) {
        this.email = email;
        this.phone = "";
        this.password = password;
        this.nickname = nickname;
        this.header = header;
        this.gender = 0;
        this.status = 1;
        this.createTime = new Date();
        this.introduce = "这个人很神秘什么都没介绍~";
        this.subscribeUsers = new HashSet<>();
        this.subscribeVideos = new HashSet<>();
        this.subscribeArticles = new HashSet<>();
    }
}
